# coding=utf-8
# 代码文件：chapter1/ch1.13.1-1.py

# 通过w+模式打开文件test.txt
fobj = open('test1.txt', 'w+', encoding='utf-8')

# write函数写入字符串到文件
fobj.write('大家好')

fname1 = r'C:\\Users\tony\\OneDrive\\书\\电子\\Python自动化办公\\code\\chapter1\\test1.txt'

# 通过a+模式打开文件test.txt
fobj = open(fname1, 'a+', encoding='utf-8')

fobj.write('！')

fname2 = r'C:\Users\tony\OneDrive\书\电子\Python自动化办公\code\chapter1\test1.txt'
fobj = open(fname2, 'r+', encoding='utf-8')
fobj.write('谢谢！')
